<!DOCTYPE html>
<html lang="cn">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
    
    </style>
</head>
<body>
    <h4>说点什么:</h4>
    <textarea name="weibo" cols="30" rows="5" placeholder="请输入140字的内容..." onkeyup="ck(this)" maxlength="140"></textarea>
    <p>
        您还能输入 <font size="5" color="red" id="ts">140</font> 个字!
    </p>

    <script>
        var ts = document.getElementById('ts');

        num = 140;
        function ck(obj){
            // console.log(obj.value);
            var n = obj.value;//获取输入值字串
            var lengths = num - n.length;//算出剩余字数
            console.log(lengths);
            ts.innerHTML = lengths;//输出显示提示
        }

    </script>
</body>
</html>